﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject;
using Project.DAL.Repository;
using Framework.DataAccess;

namespace Project.WebUI.Infrastructure.Ninject
{
    public class NinjectControllerFactory: DefaultControllerFactory
    {
        private readonly IKernel _ninjectKernel;
        public NinjectControllerFactory()
        {
            _ninjectKernel= new StandardKernel();
            AddBindings();
        }

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            return controllerType == null ? null : (IController) _ninjectKernel.Get(controllerType);
        }
        private void AddBindings()
        {            
            _ninjectKernel.Bind<IUserRepository>().To<UserRepository>();
            _ninjectKernel.Bind<IDatabaseFactory>().To<DatabaseFactory>();
            _ninjectKernel.Bind<IDepositRepository>().To<DepositRepository>();
            _ninjectKernel.Bind<IWithDrawRepository>().To<WithDrawRepository>();
            _ninjectKernel.Bind<IContactRepository>().To<ContactRepository>();
            _ninjectKernel.Bind<ICountryRepository>().To<CountryRepository>(); 
            _ninjectKernel.Bind<IStoreSecureRepositoty>().To<StoreSecureRepositoty>(); 
            _ninjectKernel.Bind<IUserService>().To<UserService>(); 
            _ninjectKernel.Bind<IUnitOfWork>().To<UnitOfWork>();   
            _ninjectKernel.Bind<ILeagueRepository>().To<LeagueRepository>();   
            _ninjectKernel.Bind<IMatchesRepository>().To<MatchesRepository>();                  
            _ninjectKernel.Bind<ISoccerTeamRepository>().To<SoccerTeamRepository>();
            _ninjectKernel.Bind<IBetRepository>().To<BetRepository>();
            _ninjectKernel.Bind<IUserbetRepository>().To<UserbetRepository>();   
            _ninjectKernel.Bind<IContentRepository>().To<ContentRepository>();
            _ninjectKernel.Bind<IBetDetailRepository>().To<BetDetailRepository>();            
            _ninjectKernel.Bind<ICommonRepository>().To<CommonRepository>();                        
            _ninjectKernel.Bind<IAnnouncementRepository>().To<AnnouncementRepository>();                        
        }
    }
}
